function security_info(){
	$.ajax({
		url: '/spider-factory/stock/security_info',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "1"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let listArr=resObj.list
			if(listArr.length>0){
					let list=listArr[0]
					$('#security_info').append(
						'<tr>'+
							'<td>A股代码</td>'+
							'<td>'+list.aStock_Code+'</td>'+
							'<td>A股简称</td>'+
							'<td>'+list.aStock_Name+'%</td>'+
						'</tr>'+
						'<tr>'+
							'<td>B股代码</td>'+
							'<td>'+list.bStock_Code+'</td>'+
							'<td>B股简称</td>'+
							'<td>'+list.bStock_Name+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>H股代码</td>'+
							'<td>'+list.hStock_Code+'</td>'+
							'<td>H股简称</td>'+
							'<td>'+list.hStock_Name+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>证券类别</td>'+
							'<td>'+list.securitiesCalssfication+'</td>'+
							'<td>律师事务所</td>'+
							'<td>'+list.lawFirm+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>会计师事务所</td>'+
							'<td colspan="3">'+list.accounting_Name+'</td>'+
						'</tr>'
					)
			}else{
				$('#security_info_show').hide()
				$('#security_info_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}

function illegalHandle() {
	$.ajax({
		url: '/spider-factory/stock/illegalHandle',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "10"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let list=resObj.list
			let num=1
			if(list.length>0){
				for(const i in list){
					$('#illegalHandle').append(
						'<tr>'+
							'<td>'+num+'</td>'+
							'<td>'+(list[i].publicationDate=="" ? "" : list[i].publicationDate.substring(0,10))+'</td>'+
							'<td>'+list[i].punishedObject+'</td>'+
							'<td>'+list[i].violationType+'</td>'+
							'<td>'+list[i].penaltyAmount+'</td>'+
							'<td>'+list[i].punishment_Type+'</td>'+
							'<td>'+list[i].disciplinary_Type+'</td>'+
							'<td>'+list[i].decisionAuthority+'</td>'+
							'<td>'+list[i].type+'</td>'+
							'<td><a href="/spider-factory/stock/illegalHandle-detail?article_public_id='+list[i].article_public_id+'&companyName='+stock+'" target="_blank">详情</a></td>'+
						'</tr>'
					)
					num+=1
				}
				if(resObj.totalPage>1){
					$('#illegalHandle').append(
						'<tr>'+
							'<td colspan="10" style="text-align:center;"><a href="/spider-factory/stock/illegalHandle-more?firm_id='+firm_id+'&companyName='+stock+'" target="_blank">查看更多</a></td>'+
						'</tr>'
					)
				}
			}else{
				$('#illegalHandle_show').hide()
				$('#illegalHandle_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}

function allotShare_detail() {
	$.ajax({
		url: '/spider-factory/stock/allotShare_detail',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "10"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let list=resObj.list
			let num=1
			if(list.length>0){
				for(const i in list){
					$('#allotShare_detail').append(
						'<tr>'+
							'<td>'+num+'</td>'+
							'<td>'+(list[i].publicationDate=="" ? "" : list[i].publicationDate.substring(0,10))+'</td>'+
							'<td>'+list[i].rightIssuePrice+'</td>'+
							'<td>'+list[i].actualTotalRightIssue+'</td>'+
							'<td>'+list[i].actualTotalRaise+'</td>'+
							'<td>'+(list[i].equityRegistrationDate=="" ? "" : list[i].equityRegistrationDate.substring(0,10))+'</td>'+
							'<td>'+(list[i].xrBaseDate=="" ? "" : list[i].xrBaseDate.substring(0,10))+'</td>'+
							'<td>'+list[i].rightIssueScheme+'</td>'+
						'</tr>'
					)
					num+=1
				}
			}else{
				$('#allotShare_detail_show').hide()
				$('#allotShare_detail_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}

function issue_info() {
	$.ajax({
		url: '/spider-factory/stock/issue_info',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "1"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let list=resObj.list
			if(list.length>0){
					let i=0
					$('#issue_info').html(
						'<tr>'+
							'<td>成立日期</td>'+
							'<td>'+(list[i].establishedDate=="" ? "" : list[i].establishedDate.substring(0,10))+'</td>'+
							'<td>上市日期</td>'+
							'<td>'+(list[i].launchDate=="" ? "" : list[i].launchDate.substring(0,10))+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>发行市盈率(倍)</td>'+
							'<td>'+list[i].issuePeRatio+'</td>'+
							'<td>网上发行日期</td>'+
							'<td>'+(list[i].onlineIssueDate=="" ? "" : list[i].onlineIssueDate.substring(0,10))+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>发行方式</td>'+
							'<td>'+list[i].issueType+'</td>'+
							'<td>每股面值(元)</td>'+
							'<td>'+list[i].perShare_FV+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>发行量(股)</td>'+
							'<td>'+list[i].issueAmount+'</td>'+
							'<td>每股发行价(元)</td>'+
							'<td>'+list[i].perShare_IP+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>发行费用(元)</td>'+
							'<td>'+list[i].issueCost+'</td>'+
							'<td>发行总市值(元)</td>'+
							'<td>'+list[i].issueGross_MV+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>募集资金净额(元)</td>'+
							'<td>'+list[i].raiseMoney_NA+'</td>'+
							'<td>首日开盘价(元)</td>'+
							'<td>'+list[i].firstDay_OpenP+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>首日最高价(元)</td>'+
							'<td>'+list[i].firstDay_HP+'</td>'+
							'<td>首日收盘价(元)</td>'+
							'<td>'+list[i].firstDay_CloseP+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>首日换手率</td>'+
							'<td>'+list[i].firstDay_TR+'</td>'+
							'<td>线下配售中签率</td>'+
							'<td>'+list[i].offline_DR+'</td>'+
						'</tr>'+
						'<tr>'+
							'<td>定价中签率</td>'+
							'<td colspan="3" style="width: 283px;">'+list[i].priceWinningRate+'</td>'+
						'</tr>'
					)
			}else{
				$('#issue_info_show').hide()
				$('#issue_info_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}

function additional_info() {
	$.ajax({
		url: '/spider-factory/stock/additional_info',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "10"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let list=resObj.list
			let num=1
			if(list.length>0){
				for(const i in list){
					$('#additional_info').append(
						'<tr>'+
							'<td>'+num+'</td>'+
							'<td>'+(list[i].additionalIssueDate==undefined ? "" : list[i].additionalIssueDate.substring(0,10))+'</td>'+
							'<td>'+(list[i].zengfa_number==undefined ? "" : list[i].zengfa_number)+'</td>'+
							'<td>'+(list[i].mujji_number==undefined ? "" : list[i].mujji_number)+'</td>'+
							'<td>'+(list[i].additionalIssuePrice==undefined ? "" : list[i].additionalIssuePrice)+'</td>'+
							'<td>'+(list[i].issueType==undefined ? "" : list[i].issueType)+'</td>'+
							'<td>'+(list[i].equityRegistrationDate==undefined ? "" : list[i].equityRegistrationDate.substring(0,10))+'</td>'+
							'<td>'+(list[i].additionalListDate==undefined ? "" : list[i].additionalListDate.substring(0,10))+'</td>'+
							'<td>'+(list[i].money_date==undefined ? "" : list[i].money_date.substring(0,10))+'</td>'+
						'</tr>'
					)
					num+=1
				}
				if(resObj.totalPage>1){
					$('#additional_info').append(
						'<tr>'+
							'<td colspan="9" style="text-align:center;"><a href="/spider-factory/stock/additional_info-more?firm_id='+firm_id+'&companyName='+stock+'" target="_blank">查看更多</a></td>'+
						'</tr>'
					)
				}
			}else{
				$('#additional_info_show').hide()
				$('#additional_info_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}

function manage_shareChange() {
	$.ajax({
		url: '/spider-factory/stock/manage_shareChange',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "10"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let list=resObj.list
			let num=1
			if(list.length>0){
				for(const i in list){
					$('#manage_shareChange').append(
						'<tr>'+
							'<td>'+num+'</td>'+
							'<td>'+(list[i].changeDate=="" ? "" : list[i].changeDate.substring(0,10))+'</td>'+
							'<td>'+list[i].changePersonName+'</td>'+
							'<td>'+list[i].positionTitle+'</td>'+
							'<td>'+list[i].changeShareQuantity+'</td>'+
							'<td>'+list[i].balanceShareQuantity+'</td>'+
							'<td>'+list[i].shareChangeWay+'</td>'+
						'</tr>'
					)
					num+=1
				}
				if(resObj.totalPage>1){
					$('#manage_shareChange').append(
						'<tr>'+
							'<td colspan="7" style="text-align:center;"><a href="/spider-factory/stock/manage_shareChange-more?firm_id='+firm_id+'&companyName='+stock+'" target="_blank">查看更多</a></td>'+
						'</tr>'
					)
				}
			}else{
				$('#manage_shareChange_show').hide()
				$('#manage_shareChange_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}

function shareCapital() {
	$.ajax({
		url: '/spider-factory/stock/shareCapital',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "10"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let list=resObj.list
			console.log(list)
			let num=1
			if(list.length>0){
				for(const i in list){
					$('#shareCapital').append(
						'<tr>'+
							'<td>'+num+'</td>'+
							'<td>'+(list[i].publicationDate=="" ? "" : list[i].publicationDate.substring(0,10))+'</td>'+
							'<td>'+list[i].totalShareAmount+'</td>'+
							'<td>'+list[i].shareAmount+'</td>'+
							'<td>'+list[i].yiliutonf_A+'</td>'+
							'<td>'+list[i].yiliutonf_B+'</td>'+
							'<td>'+list[i].constraintShare+'</td>'+
							'<td>'+list[i].qitachigu+'</td>'+
							'<td>'+list[i].ziranrenchigu+'</td>'+
							'<td><a href="/spider-factory/stock/shareCapital-detail?article_public_id='+list[i].article_public_id+'&companyName='+stock+'" target="_blank">详情</a></td>'+
						'</tr>'
					)
					num+=1
				}
				if(resObj.totalPage>1){
					$('#shareCapital').append(
						'<tr>'+
							'<td colspan="10" style="text-align:center;"><a href="/spider-factory/stock/shareCapital-more?firm_id='+firm_id+'&companyName='+stock+'" target="_blank">查看更多</a></td>'+
						'</tr>'
					)
				}
			}else{
				$('#shareCapital_show').hide()
				$('#shareCapital_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}

function shareholder(){
	$.ajax({
		url: '/spider-factory/stock/shareholder',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "10000"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let list=resObj.list
			let num=1
			if(list.length>0){
				let count=0
				let index=0
				let dateArr=[]
				while(count<resObj.totalData/10){
					dateArr.push(list[index].publish_time.substring(0,10))
					index+=10
					count+=1
				}
				for(const date of dateArr){
					$('#filterDate2').append('<option>'+date+'</option>')
				}
				for(let i=0;i<10;i++){
					$('#shareholder').append(
						'<tr>'+
							'<td>'+num+'</td>'+
							'<td>'+list[i].name+'</td>'+
							'<td>'+list[i].sharetype+'</td>'+
							'<td>'+list[i].shares+'</td>'+
							'<td>'+list[i].percentage+'%</td>'+
							'<td>'+list[i].share_change+'</td>'+
							'<td>'+list[i].share_changeRatio+'</td>'+
							'<td>'+(list[i].publish_time=="" ? "" : list[i].publish_time.substring(0,10))+'</td>'+
							'<td>'+list[i].shareholder_type+'</td>'+
						'</tr>'
					)
					num+=1
				}
			}else{
				$('#shareholder_show').hide()
				$('#shareholder_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}
function shareholderByDate(){
	let filterDate=$('#filterDate2').val()
	$.ajax({
		url: '/spider-factory/stock/shareholder',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "10",
			date: filterDate+" 00:00:00"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let list=resObj.list
			let num=1
			if(list.length>0){
				$('#shareholder').html('')
				for(const i in list){
					$('#shareholder').append(
							'<tr>'+
								'<td>'+num+'</td>'+
								'<td>'+list[i].name+'</td>'+
								'<td>'+list[i].sharetype+'</td>'+
								'<td>'+list[i].shares+'</td>'+
								'<td>'+list[i].percentage+'%</td>'+
								'<td>'+list[i].share_change+'</td>'+
								'<td>'+list[i].share_changeRatio+'</td>'+
								'<td>'+(list[i].publish_time=="" ? "" : list[i].publish_time.substring(0,10))+'</td>'+
								'<td>'+list[i].shareholder_type+'</td>'+
							'</tr>'
						)
						num+=1
				}
			}else{
				$('#shareholder_show').hide()
				$('#shareholder_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}

function circulate_shareholder() {
	$.ajax({
		url: '/spider-factory/stock/circulate_shareholder',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "10000"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let list=resObj.list
			let num=1
			if(list.length>0){
				let count=0
				let index=0
				let dateArr=[]
				while(count<resObj.totalData/10){
					dateArr.push(list[index].publish_time.substring(0,10))
					index+=10
					count+=1
				}
				for(const date of dateArr){
					$('#filterDate').append('<option>'+date+'</option>')
				}
				for(let i=0;i<10;i++){
					$('#circulate_shareholder').append(
						'<tr>'+
							'<td>'+num+'</td>'+
							'<td>'+list[i].name+'</td>'+
							'<td>'+list[i].sharetype+'</td>'+
							'<td>'+list[i].shares+'</td>'+
							'<td>'+list[i].share_change+'</td>'+
							'<td>'+list[i].percentage+'%</td>'+
							'<td>'+list[i].share_changeRatio+'</td>'+
						'</tr>'
					)
					num+=1
				}
			}else{
				$('#circulate_shareholder_show').hide()
				$('#circulate_shareholder_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}
function circulate_shareholderByDate() {
	let filterDate=$('#filterDate').val()
	$.ajax({
		url: '/spider-factory/stock/circulate_shareholder',
		type: 'POST',
		data: {
			firm_id: firm_id,
			page: "1",
			size: "10",
			date: filterDate+" 00:00:00"
		},
		success: function(res){
			let resObj=JSON.parse(res)
			let list=resObj.list
			let num=1
			if(list.length>0){
				$('#circulate_shareholder').html('')
				for(const i in list){
					$('#circulate_shareholder').append(
							'<tr>'+
								'<td>'+num+'</td>'+
								'<td>'+list[i].name+'</td>'+
								'<td>'+list[i].sharetype+'</td>'+
								'<td>'+list[i].shares+'</td>'+
								'<td>'+list[i].share_change+'</td>'+
								'<td>'+list[i].percentage+'%</td>'+
								'<td>'+list[i].share_changeRatio+'</td>'+
							'</tr>'
						)
						num+=1
				}
			}else{
				$('#circulate_shareholder_show').hide()
				$('#circulate_shareholder_show').prev().hide()
			}
		},
		error: function(res){
			console.log(res)
		}
	})
}